package business
{
    import com.adobe.cairngorm.business.ServiceLocator;
    
    import mx.collections.*;
    import mx.rpc.*;
    import mx.rpc.remoting.*;
    	
	public class MsgDelegate
	{
		private var responder:Object;
        private var service:RemoteObject;

        public function MsgDelegate(re:Object)
        {
            this.service = ServiceLocator.getInstance().getRemoteObject("messageService");
            this.responder = re;
        }
        
        public function getConfigs():void
        {
            var token:AsyncToken;
            var itemResponder:ItemResponder;
            token = service.getConfigs();
            itemResponder = new ItemResponder(responder["getConfigsResult"],responder["fault"] );
            token.addResponder(itemResponder);
        }
                
        public function getSiteMessages(page:int):void
        {
            var token:AsyncToken;
            var itemResponder:ItemResponder;
            token = service.getSiteMessages(page);
            itemResponder = new ItemResponder(responder["getSiteMessagesResult"],responder["fault"] );
            token.addResponder(itemResponder);
        }
        
        public function removeSiteMessages(page:int, ids:Array):void
        {
            var token:AsyncToken;
            var itemResponder:ItemResponder;
            token = service.removeSiteMessages(page, ids);
            itemResponder = new ItemResponder(responder["removeSiteMessagesResult"],responder["fault"] );
            token.addResponder(itemResponder);
        }
        
        public function updateSiteMessage(updated:Object):void
        {
            var token:AsyncToken;
            var itemResponder:ItemResponder;
            token = service.updateSiteMessage(updated);
            itemResponder = new ItemResponder(responder["updateSiteMessageResult"],responder["fault"] );
            token.addResponder(itemResponder);
        }
        
        public function addSiteMessage(item:Object):void
        {
            var token:AsyncToken;
            var itemResponder:ItemResponder;
            token = service.addSiteMessage(item);
            itemResponder = new ItemResponder(responder["addSiteMessageResult"],responder["fault"] );
            token.addResponder(itemResponder);
        }
	}
}